package com.hdp.jetpack_mvvm.lifecycle

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import com.hdp.jetpack_mvvm.R
import kotlinx.android.synthetic.main.activity_lifecycle1.*

class LifecycleActivity1 : AppCompatActivity() {
    val TAG = "LifecycleActivity"
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_lifecycle1)
        init()
    }

    fun init() {
        btn_next.setOnClickListener {
            startActivity(Intent(this, LifecycleActivity2::class.java))
        }

        lifecycle.addObserver(LifecycleObserver1(this) {
            Log.e(TAG, it)
        })
//        lifecycle.addObserver(LifecycleObserver2() {
//            Log.e(TAG, it)
//        })
    }
}